package com.omronservice.app.curve.service;


import com.omronservice.app.curve.bean.maincurve.SelectAllDataBean;
import com.omronservice.app.curve.bean.maincurve.SelectAllDataResBean;
import com.omronservice.app.curve.bean.maincurve.SelectCapacityBean;
import com.omronservice.app.curve.bean.maincurve.SelectEquBean;
import com.omronservice.app.curve.bean.sfcurve.SFCurveBean;
import com.omronservice.app.curve.mapper.CurveMapper;
import com.omronservice.app.curve.mapper.SFCurveMapper;
import com.omronservice.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
public class SFCurveService {


    @Autowired
    SFCurveMapper sfCurveMapper;


    public SFCurveBean getData(String startDate,String endDate,String startDate2,String endDate2,String type,String line,String selectType) {
        SFCurveBean sfCurveBean=new SFCurveBean();
        List list1=new ArrayList();
        List list2=new ArrayList();

        if("1".equals(selectType)){
            if(StringUtils.isNotEmpty(startDate2)&&StringUtils.isNotEmpty(endDate2)){
                switch (type){
                    case "1":
                        list1 = sfCurveMapper.selectSf(startDate,endDate,"1",line);
                        list2 = sfCurveMapper.selectSf(startDate2,endDate2,"1",line);
                        break;
                    case "2":
                        list1 = sfCurveMapper.selectSf(startDate,endDate,"2",line);
                        list2 = sfCurveMapper.selectSf(startDate2,endDate2,"2",line);
                        break;
                    case "3":
                        list1 = sfCurveMapper.selectHaml(startDate,endDate,"4",line);
                        list2 = sfCurveMapper.selectHaml(startDate2,endDate2,"4",line);
                        break;
                    case "4":
                        list1 = sfCurveMapper.selectHaml(startDate,endDate,"1",line);
                        list2 = sfCurveMapper.selectHaml(startDate2,endDate2,"1",line);
                        break;
                    case "5":
                        list1 = sfCurveMapper.selectHaml(startDate,endDate,"2",line);
                        list2 = sfCurveMapper.selectHaml(startDate2,endDate2,"2",line);
                        break;
                    default:break;
                }
                sfCurveBean.setaList(list1);
                sfCurveBean.setbList(list2);

            }else {
                switch (type){
                    case "1":
                        list1 = sfCurveMapper.selectSf(startDate,endDate,"1",line);
                        break;
                    case "2":
                        list1 = sfCurveMapper.selectSf(startDate,endDate,"2",line);
                        break;
                    case "3":
                        list1 = sfCurveMapper.selectHaml(startDate,endDate,"4",line);
                        break;
                    case "4":
                        list1 = sfCurveMapper.selectHaml(startDate,endDate,"1",line);
                        break;
                    case "5":
                        list1 = sfCurveMapper.selectHaml(startDate,endDate,"2",line);
                        break;
                    default:break;
                }
                sfCurveBean.setaList(list1);
                sfCurveBean.setbList(list2);
            }
        }else if("2".equals(selectType)){//按照小时 //TODO

            if(StringUtils.isNotEmpty(startDate2)&&StringUtils.isNotEmpty(endDate2)){
                switch (type){
                    case "1":
                        list1 = sfCurveMapper.selectSfByHour(startDate,endDate,"1",line);
                        list2 = sfCurveMapper.selectSfByHour(startDate2,endDate2,"1",line);
                        break;
                    case "2":
                        list1 = sfCurveMapper.selectSfByHour(startDate,endDate,"2",line);
                        list2 = sfCurveMapper.selectSfByHour(startDate2,endDate2,"2",line);
                        break;
                    case "3":
                        list1 = sfCurveMapper.selectHamlByHour(startDate,endDate,"4",line);
                        list2 = sfCurveMapper.selectHamlByHour(startDate2,endDate2,"4",line);
                        break;
                    case "4":
                        list1 = sfCurveMapper.selectHamlByHour(startDate,endDate,"1",line);
                        list2 = sfCurveMapper.selectHamlByHour(startDate2,endDate2,"1",line);
                        break;
                    case "5":
                        list1 = sfCurveMapper.selectHamlByHour(startDate,endDate,"2",line);
                        list2 = sfCurveMapper.selectHamlByHour(startDate2,endDate2,"2",line);
                        break;
                    default:break;
                }
                sfCurveBean.setaList(list1);
                sfCurveBean.setbList(list2);

            }else {
                switch (type){
                    case "1":
                        list1 = sfCurveMapper.selectSfByHour(startDate,endDate,"1",line);
                        break;
                    case "2":
                        list1 = sfCurveMapper.selectSfByHour(startDate,endDate,"2",line);
                        break;
                    case "3":
                        list1 = sfCurveMapper.selectHamlByHour(startDate,endDate,"4",line);
                        break;
                    case "4":
                        list1 = sfCurveMapper.selectHamlByHour(startDate,endDate,"1",line);
                        break;
                    case "5":
                        list1 = sfCurveMapper.selectHamlByHour(startDate,endDate,"2",line);
                        break;
                    default:break;
                }
                sfCurveBean.setaList(list1);
                sfCurveBean.setbList(list2);
            }

        }else if("3".equals(selectType)){//按照分钟 //TODO

            if(StringUtils.isNotEmpty(startDate2)&&StringUtils.isNotEmpty(endDate2)){
                switch (type){
                    case "1":
                        list1 = sfCurveMapper.selectSfBySec(startDate,endDate,"1",line);
                        list2 = sfCurveMapper.selectSfBySec(startDate2,endDate2,"1",line);
                        break;
                    case "2":
                        list1 = sfCurveMapper.selectSfBySec(startDate,endDate,"2",line);
                        list2 = sfCurveMapper.selectSfBySec(startDate2,endDate2,"2",line);
                        break;
                    case "3":
                        list1 = sfCurveMapper.selectHamlBySec(startDate,endDate,"4",line);
                        list2 = sfCurveMapper.selectHamlBySec(startDate2,endDate2,"4",line);
                        break;
                    case "4":
                        list1 = sfCurveMapper.selectHamlBySec(startDate,endDate,"1",line);
                        list2 = sfCurveMapper.selectHamlBySec(startDate2,endDate2,"1",line);
                        break;
                    case "5":
                        list1 = sfCurveMapper.selectHamlBySec(startDate,endDate,"2",line);
                        list2 = sfCurveMapper.selectHamlBySec(startDate2,endDate2,"2",line);
                        break;
                    default:break;
                }
                sfCurveBean.setaList(list1);
                sfCurveBean.setbList(list2);

            }else {
                switch (type){
                    case "1":
                        list1 = sfCurveMapper.selectSfBySec(startDate,endDate,"1",line);
                        break;
                    case "2":
                        list1 = sfCurveMapper.selectSfBySec(startDate,endDate,"2",line);
                        break;
                    case "3":
                        list1 = sfCurveMapper.selectHamlBySec(startDate,endDate,"4",line);
                        break;
                    case "4":
                        list1 = sfCurveMapper.selectHamlBySec(startDate,endDate,"1",line);
                        break;
                    case "5":
                        list1 = sfCurveMapper.selectHamlBySec(startDate,endDate,"2",line);
                        break;
                    default:break;
                }
                sfCurveBean.setaList(list1);
                sfCurveBean.setbList(list2);
            }

        }



        return sfCurveBean;

    }

}
